<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<style type="text/css"> 
.msg{float:left; line-height:1.5em; margin:0; display:block;border:1px solid #f66;padding:2px 5px;*padding:2px 5px 1px;}
.msg.rn{background-color:#fff2f2;border-color:#f66;}
</style> 
<s:url value="/images" var="imgPath"/>
<!-- 月历 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick-zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="/css/smoothness.datepick.css" />

<script language="javascript">
	$().ready( function() {
		$("#sendData").click(function(){
			if ( validateData() )
        		$("#formObj").submit();
    	});
		$("#cleanData").click(function(){
        	
        	
        	$("input[id*='sendList_']").each(function(){
				this.checked=false;				
			});
			$('#smsMsg').value="";
			$('#smsMsg').trigger("keyup");
    	});    
		$('.word_count').each(function(){
			
			var length = $(this).val().length;
			
			$(this).parent().find('.counter').html( length + ' 字');
			// bind on key up event
			$(this).keyup(function(){
				
				var new_length = $(this).val().length;
				
				$(this).parent().find('.counter').html( new_length + ' 字');
			});
		});

	});	
	function validateData(){
		var isCorrect = true;		
		var sendPPLCount = 0;
		$("input[id*='sendList_']").each(function(){
			if(this.checked) sendPPLCount++;
		});
		if(sendPPLCount==0){
			alert("请至少勾选一个收件人");
			isCorrect = false;
		}

		if($('#smsMsg').val().length>70){
			alert("短信字数已超过70字");
			isCorrect = false;
		}

		if($('#smsMsg').val().length==0){
			alert("请输入短信内容");
			isCorrect = false;
		}
		//alert(sendPPLCount);
		return isCorrect;
	}

</script>
<s:actionerror/>
<s:actionmessage/>
<s:fielderror />
<s:form action="sendUrgentSms.do" method="post" id="formObj" >
<h1>紧急短信发送:</h1>
<p>
<table class="tb-data" width="100%" >
<tr >
<th colspan="4"><b>收件人：</b></th>
</tr>
<c-rt:forEach items="${contactsKey}" var="option" varStatus="rows_index"> 
<c-rt:if test="${rows_index.count % 4 == 1}">       
<tr class="${rows_index.count % 8 == 1 ? 'bg-yl' : ''}">
</c-rt:if>	
	<td><input type="checkbox" name="sendList" id="sendList_${rows_index.count}" value="${option.code}">(${option.memo2})${option.memo1}/${option.name}</td>
	
<c-rt:if test="${rows_index.count % 4 == 0}">   
</tr>
</c-rt:if>
</c-rt:forEach>  
<tr >
<th colspan="4"><b>短信内容：</b></th>
</tr>
<tr >
<td colspan="4">
<textarea id="smsMsg" name="smsMsg" rows="5" cols="50" class="word_count"></textarea><br>
短信字数:<span class="counter"></span>
<div class="f-link">
	<a href="#" id="sendData">发送</a>
	<a href="#" id="cleanData">取消</a>
	<a href="queryUrgentSms.do" id="saveData">回查询页</a>
</div>
</td>
</tr>
</table>
</p>
<br>

<span id="errMsg" class="msg rn" style="display:none"></span>

</s:form>
